<template>
  <div class="enroll-page">
    <div class="enroll-page-header">
      <Header></Header>
    </div>
    <div class="enroll-page-main">
      <div class="enroll-page-main-box">
        <div class="top">
          <div class="enroll-page-main-box-left">
            <el-tabs
              v-model="activeName"
              style="font-size: 0.16rem; margin-top: 0.2rem"
              @tab-click="handleTabClick"
            >
              <el-tab-pane label="新用户注册" name="first">
                <div class="form">
                  <el-form
                    ref="formRules"
                    :model="form"
                    label-width="auto"
                    label-position="right"
                    :rules="rules"
                    style="width: 100%; margin-top: 0.2rem"
                  >
                    <el-form-item label="注册手机号:" prop="telephone">
                      <el-input
                        placeholder="手机号"
                        v-model="form.telephone"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="图形验证码:" prop="ImgCode">
                      <div
                        style="
                          width: 100% !important;
                          display: flex;
                          justify-content: space-between;
                          align-items: center;
                        "
                      >
                        <el-input
                          style="margin-right: 0.1rem"
                          placeholder="图形验证码"
                          v-model="form.ImgCode"
                        >
                        </el-input>
                        <!-- <validate-code ref="ref_validateCode" /> -->
                        <img
                          :src="codeImg"
                          @click="getCode"
                          class="codeImg"
                          alt=""
                        />
                      </div>
                    </el-form-item>
                    <el-form-item label="手机验证码:" prop="authCode">
                      <div class="getCode">
                        <el-input
                          style="width: 2.35rem; margin-right: 0.1rem"
                          placeholder="手机验证码"
                          v-model="form.authCode"
                        >
                        </el-input>
                        <div
                          class="getCodeButton"
                          @click="getSmsC"
                          v-if="showB"
                        >
                          获取验证码
                        </div>
                        <div class="getCodeButton" v-else>
                          {{ timeB }}秒后重新获取
                        </div>
                      </div>
                    </el-form-item>
                    <el-form-item label="设置密码:" prop="password">
                      <el-input
                        :type="flagType"
                        placeholder="请输入"
                        v-model="form.password"
                      >
                        <i
                          slot="suffix"
                          :class="[
                            this.flag
                              ? 'iconfont icon-yanjing-zhengyan'
                              : 'iconfont icon-biyan',
                          ]"
                          style="margin-top: 8px; font-size: 18px"
                          @click="getFlag()"
                        ></i>
                      </el-input>
                    </el-form-item>
                    <el-form-item label="确认密码:" prop="confirmpasswordTow">
                      <el-input
                        :type="flagType1"
                        placeholder="请输入"
                        v-model="form.confirmpasswordTow"
                      >
                        <i
                          slot="suffix"
                          :class="[
                            this.flag1
                              ? 'iconfont icon-yanjing-zhengyan'
                              : 'iconfont icon-biyan',
                          ]"
                          style="margin-top: 8px; font-size: 18px"
                          @click="getFlag1()"
                        ></i
                      ></el-input>
                    </el-form-item>
                    <div class="xieyi">
                      <el-checkbox v-model="checked"></el-checkbox>请阅读并同意
                      <router-link :to="{ path: '/xieyi' }" target="_blank">
                        <el-button type="text"
                          >《望江童装网平台服务协议》</el-button
                        ></router-link
                      >
                    </div>
                    <div class="loginbutton" @click="register">注册</div>
                    <div class="tologin" @click="$router.push('/login')">
                      已有账号，返回登录>>
                    </div>
                  </el-form>
                </div>
              </el-tab-pane>

              <el-tab-pane label="供应商入驻" name="1">
                <div class="form">
                  <el-form
                    ref="formData"
                    :model="formStore"
                    label-width="auto"
                    label-position="right"
                    :rules="rules"
                    style="width: 100%; margin-top: 0.2rem"
                  >
                    <el-form-item label="注册手机号:" prop="telephone">
                      <el-input
                        placeholder="手机号"
                        v-model="formStore.telephone"
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="图形验证码:" prop="ImgCode">
                      <div
                        style="
                          width: 100% !important;
                          display: flex;
                          justify-content: space-between;
                          align-items: center;
                        "
                      >
                        <el-input
                          style="width: 2.35rem; margin-right: 0.1rem"
                          placeholder="图形验证码"
                          v-model="formStore.ImgCode"
                        >
                        </el-input>
                        <img
                          :src="codeImg"
                          @click="getCode"
                          class="codeImg"
                          alt=""
                        />
                      </div>
                    </el-form-item>
                    <el-form-item label="手机验证码:" prop="authCode">
                      <div class="getCode">
                        <el-input
                          style="width: 2.35rem; margin-right: 0.1rem"
                          placeholder="手机验证码"
                          v-model="formStore.authCode"
                        >
                        </el-input>
                        <div class="getCodeButton" @click="getSmsB" v-if="show">
                          获取验证码
                        </div>
                        <div class="getCodeButton" v-else>
                          {{ time }}秒后重新获取
                        </div>
                      </div>
                    </el-form-item>
                    <el-form-item label="设置密码:" prop="password">
                      <el-input
                        :type="flagType"
                        placeholder="请输入"
                        v-model="formStore.password"
                      >
                        <i
                          slot="suffix"
                          :class="[
                            this.flag
                              ? 'iconfont icon-yanjing-zhengyan'
                              : 'iconfont icon-biyan',
                          ]"
                          style="margin-top: 8px; font-size: 18px"
                          @click="getFlag()"
                        ></i
                      ></el-input>
                    </el-form-item>
                    <el-form-item label="确认密码:" prop="confirmpassword">
                      <el-input
                        :type="flagType1"
                        placeholder="请输入"
                        v-model="formStore.confirmpassword"
                      >
                        <i
                          slot="suffix"
                          :class="[
                            this.flag1
                              ? 'iconfont icon-yanjing-zhengyan'
                              : 'iconfont icon-biyan',
                          ]"
                          style="margin-top: 8px; font-size: 18px"
                          @click="getFlag1()"
                        ></i
                      ></el-input>
                    </el-form-item>
                  </el-form>
                </div>
              </el-tab-pane>
            </el-tabs>
          </div>

          <div class="enroll-page-main-box-right">
            <img
              class="logobg"
              src="../../assets/image/enroll/logobg.png"
              alt=""
            />
            <div class="logotext">www.wjtzw.cn</div>
            <div class="enroll-page-main-box-right-msgbox">
              <div class="text1">官方客服微信</div>
              <div class="text2">优质客源</div>
              <div class="text3">欢迎您的加入</div>
              <div class="text5">供货商家自己的供货平台</div>
              <div class="text4">网店供货平台</div>
              <div class="text6">
                <i class="el-icon-warning-outline" style="color: red"></i>
                如遇任何问题请及时联系客服解决
              </div>
              <div class="text7"></div>
              <div class="text8">扫码添加</div>
              <div class="text9">进同行交流群</div>
              <div class="qrcodebox">
                <img
                  class="qrcode"
                  src="../../assets/image/help/icon5.png"
                  alt=""
                />
              </div>
            </div>
          </div>
        </div>

        <el-divider
          v-if="activeName == '1' ? true : false"
          content-position="center"
          ><span style="font-size: 0.16rem; color: #000000"
            >填写店铺资料</span
          ></el-divider
        >

        <div
          class="enroll-page-main-box-bottom"
          v-if="activeName == '1' ? true : false"
        >
          <el-form
            label-width="160px"
            label-position="right"
            :model="formInline"
            class="demo-form-inline"
            style="width: 100%"
            :rules="rules"
            ref="newForm"
          >
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="店铺名称:" prop="storeName">
                  <el-input
                    style="width: 3.68rem"
                    v-model="formInline.storeName"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label="店铺联系人:" prop="memberName">
                  <el-input
                    style="width: 3.68rem"
                    v-model="formInline.memberName"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="联系电话:" prop="storePhone">
                  <el-input
                    style="width: 3.68rem"
                    v-model="formInline.storePhone"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label="店铺地址:" prop="storeAddressDetail">
                  <el-input
                    style="width: 3.68rem"
                    v-model="formInline.storeAddressDetail"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="所在市场:" prop="storeMarket">
                  <el-select
                    style="width: 3.68rem"
                    v-model="formInline.storeMarket"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="(item, index) in scData"
                      :key="index"
                      :label="item.name"
                      :value="item.name"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label="微信号:">
                  <el-input
                    style="width: 3.68rem"
                    v-model="formInline.storeVx"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="邮箱:">
                  <el-input
                    style="width: 3.68rem"
                    v-model="formInline.storeEmail"
                    placeholder="请输入"
                  ></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="微信二维码:" label-width="140px">
                  <el-upload
                    :action="action + '/common/upload/file'"
                    list-type="picture-card"
                    :on-success="handleAvatarSuccess"
                    :on-remove="onRemove"
                    :before-upload="beforeAvatarUpload"
                    :show-file-list="false"
                  >
                    <img
                      style="width: 100%; height: 100%"
                      v-if="formInline.storeQrcode"
                      :src="formInline.storeQrcode"
                      class="avatar"
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item
                  label="身份证人像面:"
                  label-width="140px"
                  :required="true"
                >
                  <el-upload
                    :action="action + '/common/upload/file'"
                    list-type="picture-card"
                    :on-success="handleAvatarSuccessB"
                    :on-remove="onRemove"
                    :before-upload="beforeAvatarUpload"
                    :show-file-list="false"
                  >
                    <img
                      style="width: 100%; height: 100%"
                      v-if="formInline.idCardFront"
                      :src="formInline.idCardFront"
                      class="avatar"
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item
                  label="身份证国徽面:"
                  label-width="140px"
                  :required="true"
                >
                  <el-upload
                    :action="action + '/common/upload/file'"
                    list-type="picture-card"
                    :on-success="handleAvatarSuccessC"
                    :on-remove="onRemove"
                    :before-upload="beforeAvatarUpload"
                    :show-file-list="false"
                  >
                    <img
                      style="width: 100%; height: 100%"
                      v-if="formInline.idCardBack"
                      :src="formInline.idCardBack"
                      class="avatar"
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item
                  label="营业执照:"
                  label-width="140px"
                  :required="true"
                >
                  <el-upload
                    :action="action + '/common/upload/file'"
                    list-type="picture-card"
                    :on-success="handleAvatarSuccessD"
                    :on-remove="onRemove"
                    :before-upload="beforeAvatarUpload"
                    :show-file-list="false"
                  >
                    <img
                      style="width: 100%; height: 100%"
                      v-if="formInline.businessLicense"
                      :src="formInline.businessLicense"
                      class="avatar"
                    />
                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row>
            <el-divider></el-divider>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="售后服务:" label-width="120px">
                  <el-checkbox
                    disabled
                    v-model="formInline.returnGoods"
                    label="支持15天退货"
                  ></el-checkbox>
                  <el-checkbox
                    disabled
                    v-model="formInline.exchangeGoods"
                    label="支持15天换货"
                  ></el-checkbox>
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row>
            <!-- <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="店铺域名:" label-width="120px">
                  http：//
                  <el-input
                    style="width: 1.5rem"
                    v-model="formInline.storeDomainName"
                    placeholder="请输入"
                  ></el-input>
                  .wjtzw.cn
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row> -->
            <div class="xieyi" style="font-size: 0.14rem; margin-left: 0.7rem">
              <el-checkbox v-model="checked"></el-checkbox>请阅读并同意
              <router-link :to="{ path: '/xieyi' }" target="_blank">
                <el-button type="text"
                  >《望江童装网平台服务协议》</el-button
                ></router-link
              >和
              <router-link :to="{ path: '/fenxiao' }" target="_blank">
                <el-button type="text">《开通分销招募服务》</el-button>
              </router-link>
            </div>
            <el-divider></el-divider>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="">
                  <div class="enrollButton" @click="registerStore">注册</div>
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="space-between">
              <el-col :span="11">
                <el-form-item label="">
                  <div class="returnLogin" @click="$router.push('/login')">
                    已有账号，返回登录>>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="11"></el-col>
            </el-row>
          </el-form>
        </div>
      </div>
    </div>

    <div class="enroll-page-bottom">
      <Bottom></Bottom>
    </div>
  </div>
</template>

<script>
import md5 from "js-md5";
import imgPath from "@/utils/config";
import {
  registerPhone,
  getCode,
  getSms,
  registerStore,
  selectMarketLocation,
} from "@/api/enroll";
import { selectAllByType } from "@/api/seller/management";
import Header from "../../components/header/header.vue";
import validateCode from "@/components/ValidateCode";
import Bottom from "../../components/bottom";
import { v4 as uuidv4 } from "uuid";
export default {
  components: {
    Header,
    validateCode,
    Bottom,
  },
  data() {
    const sjhreg =
      /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
    const mmreg =
      /(?=.*?[A-Z].*?)(?=.*?[a-z].*?)(?=.*\d)(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{12,12}/;
    const validatesjh = (rule, value, callback) => {
      if (value == "") {
        callback(new Error("请输入手机号"));
      } else if (!sjhreg.test(value)) {
        callback(new Error("请检查手机号码是否正确"));
      } else {
        callback();
      }
    };
    const validatemm = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (!mmreg.test(value)) {
          callback(new Error("请输入12位，需包含大小写字母、数字以及字符"));
        }
        callback();
      }
    };
    const changePassWord = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (this.formStore.password !== this.formStore.confirmpassword) {
          callback(new Error("两次密码不一致"));
        } else if (!mmreg.test(value)) {
          callback(new Error("请输入12位，需包含大小写字母、数字以及字符"));
        }
        callback();
      }
    };
    const changePassWordTow = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (this.form.password !== this.form.confirmpasswordTow) {
          callback(new Error("两次密码不一致"));
        } else if (!mmreg.test(value)) {
          callback(new Error("请输入12位，需包含大小写字母、数字以及字符"));
        }
        callback();
      }
    };
    return {
      action: "",
      checked: false,
      flag: false,
      flagType: "password",
      flag1: false,
      flagType1: "password",
      show: true,
      showB: true,
      time: 60,
      timeB: 60,
      codeImg: "",
      showError: true,
      activeName: "first",
      form: {
        name: "",
        password: "",
      },
      rules: {
        telephone: [
          { required: true, validator: validatesjh, trigger: "blur" },
        ],
        password: [{ required: true, validator: validatemm, trigger: "blur" }],
        confirmpassword: [
          { required: true, validator: changePassWord, trigger: "blur" },
        ],
        confirmpasswordTow: [
          { required: true, validator: changePassWordTow, trigger: "blur" },
        ],
        authCode: [
          { required: true, message: "请输入手机验证码", trigger: "blur" },
        ],
        ImgCode: [
          { required: true, message: "请输入图形验证码", trigger: "blur" },
        ],
        storeName: [
          { required: true, message: "请输入店铺名称", trigger: "blur" },
        ],
        memberName: [
          { required: true, message: "请输入店铺联系人", trigger: "blur" },
        ],
        storePhone: [
          { required: true, validator: validatesjh, trigger: "blur" },
        ],
        storeAddressDetail: [
          { required: true, message: "请输入店铺地址", trigger: "blur" },
        ],
        storeMarket: [
          { required: true, message: "请选择所在市场", trigger: "change" },
        ],
        idCardFront: [
          { required: true, message: "请上传身份证正面", trigger: "blur" },
        ],
        idCardBack: [
          { required: true, message: "请上传身份证反面", trigger: "blur" },
        ],
        businessLicense: [
          { required: true, message: "请上传营业执照", trigger: "blur" },
        ],
       
      },
      formInline: {
        returnGoods: true,
        exchangeGoods: true,
      },
      formStore: {
        username: "",
      },
      scData: [],
      uuid:'',
    };
  },
  created() {
    this.action = imgPath.imgPath;
    this.getCode();
    this.selectAllByType();
    if(this.$route.query.index){
      this.activeName=this.$route.query.index
    }
  },
  activated() {
    this.getCode();
    this.form = {};
    this.formInline = {
      returnGoods: true,
      exchangeGoods: true,
    };
    this.formStore = {};
  },
  methods: {
    // 小眼睛切换状态
    getFlag() {
      this.flag = !this.flag;
      this.flagType = this.flag ? "text" : "password"; // text为显示密码；password为隐藏密码
    },
    getFlag1() {
      this.flag1 = !this.flag1;
      this.flagType1 = this.flag1 ? "text" : "password"; // text为显示密码；password为隐藏密码
    },
    // 获取市场数据
    selectAllByType() {
      selectMarketLocation( {
          nameKeyWord:'Market'
        }).then((data) => {
        this.scData = data.data;
      });
    },
    handleAvatarSuccess(res) {
      console.log(res);
      this.formInline.storeQrcode = res.data;
      console.log(this.formInline.storeQrcode);
      this.$forceUpdate();
    },
    handleAvatarSuccessB(res) {
      console.log(res);
      this.formInline.idCardFront = res.data;
      this.$refs.newForm.clearValidate(["idCardFront"], (errorMessage) => {
        const valid = errorMessage == "";
      });
      console.log(this.formInline.storeQrcode);
      this.$forceUpdate();
    },
    handleAvatarSuccessC(res) {
      console.log(res);
      this.formInline.idCardBack = res.data;
      this.$refs.newForm.clearValidate(["idCardBack"], (errorMessage) => {
        const valid = errorMessage == "";
      });
      console.log(this.formInline.storeQrcode);
      this.$forceUpdate();
    },
    handleAvatarSuccessD(res) {
      console.log(res);
      this.formInline.businessLicense = res.data;
      this.$refs.newForm.clearValidate(["businessLicense"], (errorMessage) => {
        const valid = errorMessage == "";
      });
      console.log(this.formInline.storeQrcode);
      this.$forceUpdate();
    },
    //图片校验
    beforeAvatarUpload(file) {
      const isLt2M = file.size / 1024 / 1024 < 3;
      if (!isLt2M) {
        this.$message.error("上传附件大小不能超过 3MB!");
        return false;
      }
      const isJPEG = file.type === "image/jpeg";
      const isJPG = file.type === "image/jpg";
      const isPNG = file.type === "image/png";
      var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
      const isPDF = testmsg === "pdf";
      if (!isJPEG && !isJPG && !isPNG && !isPDF) {
        this.$message.error("上传图片只能是 png,jpg,pdf 格式!");
        return false;
      }
      this.loading = true;
      return true;
    },
    onRemove() {
      this.formInline.storeQrcode = "";
    },
    // 供应商注册
    registerStore() {
      if (!this.checked) {
        this.$message({
          message:
            "请阅读并同意《望江童装网平台服务协议》和《开通分销招募服务》",
          type: "warning",
        });
        return false;
      }
      if (!this.formInline.idCardFront) {
        this.$message({
          message:
            "请上传身份证人像面",
          type: "warning",
        });
        return false;
      }
      if (!this.formInline.idCardBack) {
        this.$message({
          message:
            "请上传身份证国徽面",
          type: "warning",
        });
        return false;
      }
      if (!this.formInline.businessLicense) {
        this.$message({
          message:
            "请上传营业执照",
          type: "warning",
        });
        return false;
      }
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.$refs.newForm.validate((valid) => {
            if (valid) {
              const params = JSON.parse(JSON.stringify(this.formStore));
              params.password = md5(params.password);
              registerStore(params, this.formInline).then((data) => {
                if (data.code == 200) {
                  this.$message({
                    message: "申请成功，等待平台管理员审核",
                    type: "success",
                  });
                  this.$router.push("/login");
                }
              });
            } else {
              return false;
            }
          });
        } else {
          return false;
        }
      });
    },
    // 获取短信验证码
    getSmsB() {
      this.$refs.formData.validateField(["ImgCode"], (errorMessage) => {
        const valid = errorMessage == "";
        if (valid) {
          this.$refs.formData.validateField(["telephone"], (errorMessage) => {
            const valid = errorMessage == "";
            if (valid) {
              const params = {
                mobile: this.formStore.telephone,
                imageCode: this.formStore.ImgCode,
                type: "REGISTER",
              };

              getSms(params,this.uuid).then((data) => {
                if (data.code == 200) {
                  this.$message({
                    message: "短信验证码发送成功",
                    type: "success",
                  });
                  this.show = false;
                  const timer = setInterval(() => {
                    if (this.time > 0) {
                      this.time--;
                    } else {
                      this.show = true;
                      this.time = 60;
                      clearInterval(timer);
                    }
                  }, 1000);
                } else {
                  this.getCode();
                }
              });
            } else {
              return false;
            }
          });
        } else {
          return false;
        }
      });
    },
    getSmsC() {
      this.$refs.formRules.validateField(["ImgCode"], (errorMessage) => {
        const valid = errorMessage == "";
        if (valid) {
          this.$refs.formRules.validateField(["telephone"], (errorMessage) => {
            const valid = errorMessage == "";
            if (valid) {
              const params = {
                mobile: this.form.telephone,
                imageCode: this.form.ImgCode,
                type: "REGISTER",
               
              };

              getSms(params, this.uuid).then((data) => {
                if (data.code == 200) {
                  this.$message({
                    message: "短信验证码发送成功",
                    type: "success",
                  });
                  this.showB = false;
                  const timer = setInterval(() => {
                    if (this.timeB > 0) {
                      this.timeB--;
                    } else {
                      this.showB = true;
                      this.timeB = 60;
                      clearInterval(timer);
                    }
                  }, 1000);
                } else {
                  this.getCode();
                }
              });
            } else {
              return false;
            }
          });
        } else {
          return false;
        }
      });
    },
    // 获取图形验证码
    getCode() {
      this.uuid = (uuidv4() + "").replace(/-/g, "").substring(0, 5);
      getCode(this.uuid).then((data) => {
        this.codeImg = `data:image/jpg;base64,${data.data}`;
       
      });
    },
    // 注册
    register() {
      if (!this.checked) {
        this.$message({
          message: "请阅读并同意《望江童装网平台服务协议》",
          type: "warning",
        });
        return false;
      }
      this.$refs.formRules.validate((valid) => {
        if (valid) {
          const params = {
            telephone: this.form.telephone,
            password: this.form.password,
            authCode: this.form.authCode,
            username: "",
          };
          params.password = md5(params.password);
          registerPhone(params).then((data) => {
            if (data.code == 200) {
              this.$message({
                message: "注册成功",
                type: "success",
              });
              this.$router.push("/login");
            }
          });
        } else {
          return false;
        }
      });
    },
    handleTabClick(value) {
      this.activeName = value.name;
      console.log(this.activeName);
    },
  },
};
</script>

<style scoped lang="scss">
/deep/ .el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #606266;
}
/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
  background-color: #409eff;
  border-color: #409eff;
  color: #fff;
}
/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner::after {
  border-color: #fff;
}
@import "https://at.alicdn.com/t/c/font_3269139_cl7hle1i5at.css?spm=a313x.manage_type_myprojects.i1.9.33fe3a81OONzz5&file=font_3269139_cl7hle1i5at.css";
/deep/ .el-progress-circle {
  width: 1rem !important;
  height: 1rem !important;
}

/deep/ .el-upload-list__item-actions {
  width: 1rem;
  height: 1rem;
}

/deep/ .el-upload-list__item-thumbnail {
  width: 1rem;
  height: 1rem;
}

/deep/ .el-upload-list__item {
  width: 1rem;
  height: 1rem;
}

.codeImg {
  width: 100px;
  height: 0.4rem;
  cursor: pointer;
}

.enroll-page {
  width: 100%;
  min-height: 100vh;

  &-header {
    width: 100%;
    height: 0.96rem;
  }

  &-main {
    width: 100%;
    min-height: 6.33rem;
    padding: 0.27rem 0rem;
    background: #f5f7f9;
    display: flex;
    justify-content: center;
    align-items: center;

    &-box {
      width: 12rem;
      min-height: 4.91rem;
      background: #ffffff;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: flex-start;

      .top {
        width: 12rem;
        min-height: 4.6rem;
        background: #ffffff;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
      }

      &-left {
        width: 4.63rem;
        min-height: 5.91rem;
        padding: 0 0.27rem;
        .xieyi {
          margin-left: 1rem;
          font-size: 0.14rem;

          display: flex;
          align-items: center;
        }

        .loginbutton {
          margin-top: 0.12rem;
          margin-left: calc(100% - 3.68rem);
          width: 70%;
          height: 0.4rem;
          border-radius: 0.02rem;
          opacity: 0.5;
          background: #e22a1f;
          text-align: center;
          line-height: 0.4rem;
          color: #ffffff;
          font-size: 0.16rem;
          letter-spacing: 0.04rem;
          cursor: pointer;
        }

        .form {
          .getCode {
            width: 100% !important;
            height: 0.4rem;
            margin-top: 0.07rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: relative;

            ::v-deep .el-input__inner {
              height: 0.4rem !important;
            }
          }
          ::v-deep .el-form-item {
            margin-bottom: 0.2rem;
          }

          .getCodeButton {
            width: 1.02rem;
            height: 0.38rem;
            line-height: 0.38rem;
            text-align: center;
            cursor: pointer;
            color: #fa5555;
            border: 1px solid #e22a1f;
            font-size: 0.12rem;
          }

          .message {
            margin-top: 0.15rem;
            width: 100%;
            text-align: center;
            font-family: PingFang SC;
            font-size: 0.14rem;
            color: #e22a1f;
            cursor: pointer;
          }

          .tologin {
            margin-top: 0.12rem;
            margin-left: calc(100% - 3.68rem);
            width: 3.68rem;
            text-align: left;
            color: #e22a1f;
            font-size: 0.16rem;
            cursor: pointer;
          }
        }

        ::v-deep .el-tabs__item {
          font-size: 0.16rem;
          font-weight: bold;
        }

        ::v-deep .el-tabs__item:hover {
          color: red !important;
        }

        ::v-deep .el-tabs__item.is-active {
          color: red !important;
        }

        ::v-deep .el-tabs__active-bar {
          height: 0.04rem;
          background-color: red !important;
        }

        ::v-deep .el-input__prefix {
          color: #3d3c3c !important;
        }

        ::v-deep .el-input__inner {
          height: 0.4rem !important;
        }

        ::v-deep .el-tabs__nav-wrap::after {
          background: none;
        }
      }

      &-right {
        margin-top: 0.33rem;
        margin-right: 0.32rem;
        width: 6.32rem;
        height: 4rem;
        background: #f9d4d2;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;

        .logotext {
          font-size: 0.24rem;
          color: #ffffff;
          font-weight: 500;
          position: absolute;
          top: 0.12rem;
          left: 50%;
          transform: translateX(-50%);
          z-index: 10;
        }

        .logobg {
          width: 2.4965rem;
          height: 0.5118rem;
          position: absolute;
          top: 0rem;
          left: 50%;
          transform: translateX(-50%);
          z-index: 10;
        }

        &-msgbox {
          width: 94.62%;
          height: 91%;
          background: #ffffff;
          border-radius: 0.1rem;
          position: absolute;
          display: flex;
          justify-content: center;
          align-items: center;

          .text1 {
            font-size: 0.28rem;
            color: #e22a1f;
            position: absolute;
            top: 0.48rem;
            left: 2.12rem;
          }

          .text2 {
            font-size: 0.28rem;
            color: #e22a1f;
            position: absolute;
            top: 1.14rem;
            left: 0.43rem;
          }

          .text3 {
            font-size: 0.28rem;
            color: #e22a1f;
            position: absolute;
            top: 1.54rem;
            left: 0.2rem;
          }

          .text5 {
            font-size: 0.14rem;
            color: #e22a1f;
            position: absolute;
            top: 2.11rem;
            left: 0.18rem;
          }

          .text4 {
            width: 1.18rem;
            height: 0.36rem;
            line-height: 0.36rem;
            background: #e22a1f;
            text-align: center;
            font-size: 0.16rem;
            color: #ffffff;
            position: absolute;
            top: 2.41rem;
            left: 0.49rem;
          }

          .text6 {
            font-size: 0.18rem;
            color: #e22a1f;
            position: absolute;
            top: 3.15rem;
            left: 1.49rem;
          }

          .text7 {
            font-size: 0.18rem;
            font-weight: bold;
            color: #e22a1f;
            position: absolute;
            top: 1.15rem;
            left: 4.41rem;
          }

          .text8 {
            font-size: 0.28rem;
            color: #e22a1f;
            position: absolute;
            top: 1.45rem;
            left: 4.28rem;
          }

          .text9 {
            font-size: 0.28rem;
            color: #e22a1f;
            position: absolute;
            top: 1.84rem;
            left: 4.08rem;
          }

          .qrcodebox {
            width: 1.8rem;
            height: 1.8rem;
            border-radius: 0.1rem;
            background: #e22a1f;
            display: flex;
            justify-content: center;
            align-items: center;

            .qrcode {
              width: 90%;
              height: 90%;
            }
          }
        }
      }

      &-bottom {
        width: 10.7rem;
        padding: 0rem 1rem 0rem 0.3rem;
        min-height: 4rem;
        background: #ffffff;

        .enrollButton {
          margin-left: 1.2rem;
          width: 3.68rem;
          height: 0.4rem;
          line-height: 0.4rem;
          text-align: center;
          font-size: 0.16rem;
          font-weight: 500;
          color: #ffffff;
          border-radius: 0.02rem;
          background: #e22a1f;
          cursor: pointer;
        }

        .returnLogin {
          margin-left: 1.2rem;
          width: 3.68rem;
          height: 0.2rem;
          line-height: 0.2rem;
          text-align: left;
          font-size: 0.14rem;
          font-weight: 500;
          color: #e22a1f;
          cursor: pointer;
        }

        ::v-deep .el-form-item {
          display: flex;
        }

        ::v-deep .el-upload--picture-card {
          width: 1rem;
          height: 1rem;
          line-height: 1rem;
        }
      }
    }
  }

  &-bottom {
    width: 100%;
    height: 3.2rem;
  }
}
</style>
<style scoped lang="scss">
@media screen and (max-width: 1450px) {
  .getCodeButton {
    width: 1.92rem !important;
  }

  .top {
    height: 4.9rem !important;
  }

  .text5 {
    font-size: 0.12rem !important;
  }

  .qrcodebox {
    width: 1.7rem !important;
    height: 1.7rem !important;
  }

  .enroll-page-main-box {
    min-height: 6.2rem !important;
    width: 14rem;
  }
  .enroll-page-main-box-left {
    width: 6.63rem;
  }
  .top {
    width: 14rem !important;
  }
  .loginbutton {
    margin-top: 0.35rem !important;
    margin-left: 1.5rem !important;
    width: 50% !important;
  }
  .tologin {
    margin-left: 2.3rem !important;
  }
  .el-divider {
    margin: 0.32rem 0;
  }
  /deep/.el-tabs__content {
    overflow: inherit;
  }
}
</style>
